﻿var AdManage = {
    Delete: function () {
        var ids = $("input[name='aids']").getCheckBoxValue().toString();
        if (!ids) {
            alertMsg.info('请选择要删除的广告！');
            return false;
        }
        alertMsg.confirm('确定要删除勾选的广告吗？', { okCall: function () {
            $.ajax({
                url: "Manage/Ad/Delete",
                data: { 'ids': ids },
                dataType: 'json',
                success: function (data) {
                    if (data.statusCode == DWZ.statusCode.ok) {
                        alertMsg.correct(data.message);
                        navTab.openTab(data.navTabId, data.forwardUrl, { title: data.title, fresh: true });
                    }
                }
            });
        }
        });
    },
    SaveAd: function (obj, callbackfn) {
        var name = $(obj).find("input[name='ad_name']").val();
        var content = $(obj).find("[name='content']").val();
        if (!name) {
            alertMsg.error("请填写广告名称！");
            return false;
        }
        if (!content) {
            alertMsg.error("请填写广告内容！");
            return false;
        }
        if (confirm("确定要保存广告吗？")) {
            return validateCallback(obj, callbackfn);
        }
        else {
            return false;
        }

    },
    dialogAjaxDone: function (data) {
        if (data.statusCode == DWZ.statusCode.ok) {
            $.pdialog.closeCurrent();
            navTab.openTab(data.navTabId, data.forwardUrl, { title: data.title, fresh: true });
            setTimeout(function () {
                alertMsg.correct(data.message);
            }, 500);

        }
        else if (data.statusCode == DWZ.statusCode.error) {
            alertMsg.error(data.message);
        }
    }
}